package com.hpu.service;

import android.content.Context;
import android.os.Handler;

import com.hpu.callback.CourseCallback;
import com.hpu.constants.HttpConstants;
import com.hpu.constants.ShareConstants;
import com.hpu.constants.UrlConstants;
import com.hpu.interceptor.ReceivedCookieInterceptor;
import com.hpu.tools.InternetTools;
import com.hpu.tools.OkHttpTools;
import com.hpu.tools.ShareTools;

/**
 * 课程业务类，负责访问网络获取原始的课程数据
 * @author Administrator
 *
 */
public class CourseService{

	private Handler handler;
	
	private Context context;
	
	public CourseService(Handler handler,Context context) {
		this.handler=handler;
		this.context=context;
	}

	public void getCourse() {
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
		OkHttpTools.getByCookie(new ReceivedCookieInterceptor(context),UrlConstants.INTERFACE_COURSE,
				ShareTools.get(context,ShareConstants.STORE_LOGINCOOKIE, "").toString(),
				new CourseCallback(handler));
	}

}
